cmake_minimum_required(VERSION 3.10)

# 项目名称
project(rta CXX)

# 指定 C 语言标准
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)

# 设置编译选项
set(CMAKE_C_FLAGS "-g")

# 定义源代码目录
set(SRC_DIR "src")

# 自动遍历 src 目录下的所有 .cpp 文件
file(GLOB LIB_SRCS "${SRC_DIR}/*.cpp")

# 设置测试源码（如果未指定，默认使用 main.c）
# set(TEST_SRCS "gen.cpp")
set(TEST_SRCS "main.cpp")

# 目标可执行文件名
set(TARGET ${PROJECT_NAME})

# 指定输出目录
set(OUTPUT_DIR "${CMAKE_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})

# 添加可执行目标
add_executable(${TARGET} ${LIB_SRCS} ${TEST_SRCS})
include_directories(${SRC_DIR})

add_custom_target(copy_flow ALL
    COMMAND ${CMAKE_COMMAND} -E copy
        ${CMAKE_CURRENT_SOURCE_DIR}/flow.csv
        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/flow.csv
    COMMENT "Copying flow.csv to output directory"
)

# 清理规则
add_custom_target(ca COMMAND ${CMAKE_COMMAND} -E remove_directory ${OUTPUT_DIR}/*)